<template>
	<view>
		<view class="top text-lg bgw p30 ">
			<view>联系电话</view>
			<input type="number" maxlength="11" v-model="phone" placeholder="您需要修改的手机号" value="" />
			<image @tap="phone = '' " class="demoves" src="../../static/image/icon_quxiao@2x.png"></image>
		</view>
		<view class="btn p30">
			<button @tap="send()" class="btnbg br42">确认修改</button>
		</view>
	</view>
</template>

<script>
	import {
		updateStoreInfo
	} from '@/api/api.js'
	export default {
		data() {
			return {
				shakeState: 0,
				phone: ''
			}
		},
		methods: {
			async send() {
				if (!/^1[3456789]\d{9}$/.test(this.phone)) {
					uni.showToast({
						title: '手机号不合规',
						icon: 'none'
					})
				} else {
					let data = {
						"telephone": this.phone
					}
					if (this.shakeState == 0) {
						this.shakeState = 1
						let state = await updateStoreInfo(data)
						if (state.code == 0) {
							setTimeout(() => {
								uni.navigateBack()
							}, 1000)
						} else {
							this.shakeState = 0
						}
					} 
				}
			}
		}
	}
</script>

<style lang="less" scoped>
	@import './index.less';
</style>
